package library.gui;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import library.core.Library;
import library.core.user.User;
import library.gui.scene.LoginPane;
import library.gui.scene.MainMenuPane;
import library.gui.scene.OperatePane;
import library.gui.scene.RegisterPane;

public class SystemApplication extends Application{

	public static final String TITLE = "图书馆管理系统";
	public static final Image ICON = new Image("/b2.png");
	public static final int WIDTH = 1000, HEIGHT = 680;
	public static final String[] DEPARTMENT = {
		"软件工程学院", "海洋科学学院", "人工智能学院", "物理天文学院", "数学学院"	
	};
	
	
	private Library library;
	private User currentUser;
	private Scene mainMenuScene, loginScene, registerScene;
	private Stage stage;
	
	public void setCurrentUser(User user) {
		this.currentUser = user;
	}
	
	public Library getLibrary() {
		return library;
	}
	
	public User getCurrentUser() {
		return currentUser;
	}
	
	public void toMainMenuScene() {
		this.currentUser = null;
		stage.setScene(mainMenuScene);
		stage.sizeToScene();
	}
	
	public void toLoginScene() {
		stage.setScene(loginScene);
		stage.sizeToScene();
	}
	
	public void toRegisterScene() {
		stage.setScene(registerScene);
		stage.sizeToScene();
	}
	
	public void toOperateScene() {
		stage.setScene(new Scene(new OperatePane(this)));
		stage.sizeToScene();
	}
	
	public void exit() {
		stage.close();
	}
	
	@Override
	public void start(Stage primaryStage) throws Exception {
		
		primaryStage.setTitle(TITLE);
		stage = primaryStage;
		stage.getIcons().add(ICON);
		
		library = new Library();

		mainMenuScene = new Scene(new MainMenuPane(this));
		loginScene = new Scene(new LoginPane(this));
		registerScene = new Scene(new RegisterPane(this));

		toMainMenuScene();
		primaryStage.show();
		
	}

}
